package com.kyriec.controller;

import com.baomidou.mybatisplus.extension.api.ApiController;
import com.kyriec.Util.EResult;
import com.kyriec.entity.Orders;
import com.kyriec.service.OrdersService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.Date;

/**
 * 订单(Orders)表控制层
 *
 * @author KyrieC
 * @since 2023-11-28 22:31:17
 */
@RestController
@RequestMapping("orders")
public class OrdersController extends ApiController {
    /**
     * 服务对象
     */
    @Autowired
    private OrdersService ordersService;

    @PutMapping("addOrders")
    public EResult addOrders(@RequestBody Orders orders){
        orders.setSystime(new Date());
        return  ordersService.addOrders(orders);
    }

    @GetMapping("getOrdersByUserId")
    public EResult getOrdersByUserId(@RequestParam Integer userId){
        return ordersService.getOrdersByUserId(userId);
    }


}

